#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <boost/algorithm/string/replace.hpp>

using namespace std;

int main(int argc, char *argv[])
{
    if(argc != 4)
    {
        cout << "invalid parameters" << endl;
        return 1;
    }

    char* file = argv[1];
    char* placeholder = argv[2];
    char* content = argv[3];

    ifstream is(file);
    if(is.bad())
    {
        cout << "bad file: " << file << endl;
        return 1;
    }

    stringstream ss;

    ss << is.rdbuf();
    is.close();

    string result = boost::replace_all_copy(ss.str(), placeholder, content);

    ofstream os(file);
    os.write(result.c_str(), result.size());
    os.close();

    return 0;
}